#-*- encoding:utf-8 -*-
import web
from components.render import partial

pager_configs = {
	'total' : 0,
	'perpage': 15,
	'current_page': 1,
	'url':''
}

def pager(configs={}):
	pager_configs.update(configs)

	if not pager_configs['total'] or pager_configs['total'] < pager_configs['perpage']:
		return None

	page_nums = pager_configs['total'] / pager_configs['perpage']

	if pager_configs['total'] % pager_configs['perpage']:
		page_nums += 1

	pager_configs['page_nums'] = page_nums
	
	return partial.pagination(pager_configs)
